﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Photo.Application.Core.Enum
{
    /// <summary>
    /// 枚举
    /// </summary>
    [ApiDescriptionSettings(ApiGroupConsts.Core, Module = ApiGroupConsts.Core)]
    [AllowAnonymous]
    public class EnumService : IDynamicApiController
    {
        /// <summary>
        /// 获取枚举列表
        /// 利用反射，枚举类名转枚举
        /// </summary>
        /// <param name="input">枚举目录下路径全拼,如：System.EnumSysMenuType</param>
        /// <returns></returns>
        public List<KeyValueDto> GetList(BaseInput input)
        {
            Assembly assembly = Assembly.Load("Photo.Core"); //程序集名称
            //从程序集中获取指定对象类型;
            Type type = assembly.GetType($"Photo.Core.EnumSummary.{input.Content}"); //程序集名称.类名

            return EnumUtil.EnumToList(type);
        }
    }
}
